package day_161214;

import java.util.Random;

public class SelectSort {
	public static void main(String[] args) {
		Random random = new Random();
		int arr[] = new int[10];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = random.nextInt(1000);
			System.out.print(arr[i]+" ");
		}
		 int n = arr.length;  
	        for(int k=0; k<n-1; k++) {  
	            int min = k;  
	            for(int i=k+1; i<n; i++) {  
	                if(arr[i] < arr[min]) {  
	                    min = i;  
	                }  
	            }  
	            if(k != min) {  
	                int temp = arr[k];  
	                arr[k] = arr[min];  
	                arr[min] = temp;  
	            }  
	        }
		System.out.println("");
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i]+" ");
		}
	}
}
